<%@ page import="java.util.List" %>
<%@ page import="com.xunfang.demo.entity.UserDemo" %><%--
  Created by IntelliJ IDEA.
  User: 星星在唱歌
  Date: 2022/2/17
  Time: 18:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户列表页面</title>
    <script src="${pageContext.request.contextPath}/static/js/jquery-3.4.1.js"></script>
</head>
<style>
    table{
        border-collapse: collapse;
        border-color: #000000;
        width: 800px;
    }
</style>
<body>

<span>
    欢迎您
    ${username}
    <a href="${pageContext.request.contextPath}/main?cmd=DelSession">登出</a>
</span>
<br><br><br>


<form action="${pageContext.request.contextPath}/main?cmd=main" method="post" name="form1">
    <input type="hidden" name="p" id="p">
    姓名：<input type="text" name="userName" id="" value="${queryData.queryName}"> &nbsp;&nbsp;
    学历：
    <select name="eid" id="" >
        <option value="">==请选择==</option>
        <%--使用jstl标签来动态加载下拉框数据--%>
        <c:forEach items="${educationList}" var="education">
            <option value="${education.eid}" <c:if test="${queryData.eid == education.eid}">selected</c:if>>${education.ename}</option>
        </c:forEach>
    </select>
    &nbsp;&nbsp;
    开始时间：<input type="date" name="startDate" value="${queryData.startDate}"> &nbsp;&nbsp;
    结束时间：<input type="date" name="endDate" value="${queryData.endDate}"> &nbsp;&nbsp;
    <input type="submit" value="查询">
</form>


<h1>用户列表</h1>
<table border="1">
    <thead>
        <th>编号</th>
        <th>姓名</th>
        <th>地址</th>
        <th>学历编号</th>
        <th>性别</th>
        <th>学历</th>
        <th>生日</th>
        <th>操作</th>
    </thead>
    <tbody>
        <c:forEach items="${pb.dataList}" var="user" varStatus="vs">
            <tr >
                <td>${user.id}</td>
                <td>${user.userName}</td>
                <td>${user.address}</td>
                <td>${user.sel}</td>
                <td>${user.sex}</td>
                <td>${user.ename}</td>
                <td>${user.birthday}</td>
                <td><a href="javascript:del(${user.id})">删除</a>
                    <a href="javascript:update(${user.id})">修改</a>
                </td>
            </tr>
        </c:forEach>
    </tbody>
</table>
<p>
    共${pb.pageTotal}条记录，第${pb.p}页/共${pb.pageCount}页 &nbsp;&nbsp;&nbsp;
    <a href="javascript:toPage(1)">首页</a> &nbsp;
    <a href="javascript:toPage(${pb.p-1})">上一页</a> &nbsp;
    <a href="javascript:toPage(${pb.p+1})">下一页</a> &nbsp;
    <a href="javascript:toPage(${pb.pageCount})">尾页</a> &nbsp;
</p>

<a href="${pageContext.request.contextPath}/page/index.jsp">返回登录</a>


<script>
    function del(id){
        if (confirm("是否删除")){
            window.location.href="${pageContext.request.contextPath}/main?cmd=del&id="+id;
        }
    }
    function update(id){
        window.location.href="${pageContext.request.contextPath}/main?cmd=update&id="+id;
    }

    function toPage(p){
        $("#p").val(p);
        //此处是和点击提交表单一个意思
        document.form1.submit();
    }
    <c:if test="${result == 'ok'}">
    alert("删除成功！");
    </c:if>
    <c:if test="${result == 'no'}">
    alert("删除失败！");
    </c:if>
    <c:if test="${update == 'ok'}">
    alert("修改成功！");
    </c:if>
    <c:if test="${update == 'no'}">
    alert("修改失败！");
    </c:if>

</script>


</body>
</html>
